<%@LANGUAGE="VBSCRIPT" CODEPAGE="1251"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Untitled Document</title>
</head>
<!--#include file="../Connect/Connection.asp"-->
<!--#include file="../Connect/adovbs.inc"-->
<body>
<%
Ch="C"
If Request.QueryString("method")="add" Then
	Ch="A"
End If
	
IF Request.Form("slGood"&Ch&"")<>"0" THEN
	strCompl=request.QueryString("Compl")
	Set cnn=Server.CreateObject("adoDB.connection")
	cnn.open connStr & ";Initial Catalog=i_dealer"
	
	Set rs=Server.CreateObject("ADODB.Recordset")
	sSQL = "DECLARE @sMessage nvarchar(300) exec [Goods].[usp_GetRecipientsWithoitGood] '" & Request.Form("slGood"&Ch) & "', @sMessage OUTPUT"
	response.Write sSQL
	rs.Open sSQL, cnn, 1

	Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbNewLine
	Response.Write "	var obj=parent.document.getElementById('slRecipient"&Ch&"'); " & vbNewLine
'	Response.Write "	obj.options.length = 0;" & vbNewLine
	Response.Write "	parent.document.getElementById('trEmpty"&Ch&"').style.display='none';" & vbNewLine
	Response.Write "	parent.document.getElementById('trGoods"&Ch&"').style.display='block';" & vbNewLine
	Response.Write "	parent.frm"&Ch&".btn"&Ch&".disabled=false;" & vbNewLine
	Response.Write "	parent.document.getElementById('trWait"&Ch&"').style.display='none';" & vbNewLine	
	IF NOT rs.eof THEN
		i=0
		DO WHILE NOT rs.eof
			i=i+1
'			Response.Write "alert('" & Trim(rs("Descript")) & "'+'\t'+'" & Len(Trim(rs("Descript"))) & "');"
			Response.Write "var op" & i & "=parent.document.createElement('option'); " & vbNewLine
			Response.Write "op" & i & ".value='" & rs("Recipient_ID") & "';" & vbNewLine
			Response.Write "op" & i & ".innerHTML='" & Trim(rs("Descript")) & "';" & vbNewLine
			If IsNumeric(Request.QueryString("rec")) Then
				If cInt(Request.QueryString("rec"))=cInt(rs("Recipient_ID")) Then
'					Response.Write "op" & i & ".selected=true;" & vbNewLine
					Response.Write "setTimeout( 'op" & i & ".selected=true;', 1 );"
				End If
			End If
			Response.Write "obj.appendChild(op" & i & ");" & vbNewLine
			rs.MoveNext
		LOOP
	END IF
		Response.Write "</script>" & vbNewLine	
	rs.Close
	Set rs=Nothing
ELSEIF Request.Form("slSluice"&Ch&"")="0" THEN
	Response.Write "<script language=""JavaScript"" type=""text/JavaScript"">" & vbNewLine
	Response.Write "	var obj=parent.document.getElementById('slRecipient"&Ch&"'); " & vbNewLine
	Response.Write "	obj.options.length = 0;" & vbNewLine
	Response.Write "	parent.document.getElementById('trEmpty"&Ch&"').style.display='block';" & vbNewLine
	Response.Write "	parent.document.getElementById('trGoods"&Ch&"').style.display='none';" & vbNewLine
	Response.Write "	parent.frm"&Ch&".btn"&Ch&".disabled=true;" & vbNewLine
	Response.Write "	parent.document.getElementById('trWait"&Ch&"').style.display='none';" & vbNewLine	
	Response.Write "</script>" & vbNewLine	
END IF
%>
</body>
</html>
